<?php
/**
 * Date: 6/16/12
 * Time: 2:27 PM
 */
require_once '../bootstrap.php';

// Must login
if (empty($_SESSION['admin_id'])) {
	header('Location: login.php');
}
$self = $_SERVER['PHP_SELF'];
$__page = 'sport';
// Get important fields

if( isset($_GET['del'])){
	$id = (int)$_GET['del'];
	$my_db->query("DELETE FROM sports WHERE id = $id");
	$mess = getADMSuccess("Sport record/stats has been deleted.");
}
$sports = $my_db->select_assoc('SELECT * FROM sports');
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title><?php echo $title; ?></title>

	<style type="text/css" media="all">
		@import url("css/style.css");
		@import url("css/jquery.wysiwyg.css");
		@import url("css/facebox.css");
		@import url("css/visualize.css");
		@import url("css/date_input.css");
	</style>
	<link href="css/bootstrap.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
	<script type="text/javascript" src="js/jquery.dataTables.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			$('table#dataTable').dataTable();
		});
	</script>
	<style type="text/css">
		.dataTables_filter {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
			padding: 10px 10px 10px 100px;
		}

		.dataTables_length {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
			padding: 10px 10px 10px 10px;
		}

		.dataTables_length select, .dataTables_length label, .dataTables_filter label, .dataTables_filter input {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
		}

		.dataTables_info {
			background-color: #3a87ad;
			color: #f8f8ff;
		}
	</style>
</head>
<body>
<div id="hld">

	<div class="wrapper">        <!-- wrapper begins -->

		<?php include("__menu.php");?>
		<!-- #header ends -->
		<!-- .block ends -->
		<div class="block">
			<div class="block_head">
				<div class="bheadl"></div>
				<div class="bheadr"></div>
				<h2>Ads List</h2>
			</div>
			<!-- .block_head ends -->
			<div class="block_content">
				<?php echo isset($mess)?$mess:''; ?>
				<table class="table table-striped table-bordered table-condensed" id="dataTable">
					<thead>
					<tr>
						<th>Id</th>
						<th>Sport name</th>
						<th>Image on</th>
						<th>Image off</th>
						<th>Command</th>
					</tr>
					</thead>
					<tbody>
					<?php
					foreach ($sports as $sp) {
						?>
					<tr>
						<td><?= htmlspecialchars($sp['id'], ENT_QUOTES, 'UTF-8')  ?></td>
						<td><?= htmlspecialchars($sp['name'], ENT_QUOTES, 'UTF-8') ?></td>
						<td><?= htmlspecialchars($sp['image_on'], ENT_QUOTES, 'UTF-8') ?></td>
						<td><?= htmlspecialchars($sp['image_off'], ENT_QUOTES, 'UTF-8') ?></td>
						<td>
							<a href="add_edit_sport.php?id=<?= $sp['id'] ?>" title="Edit"><img src="images/edit_icon.gif" width="16" height="16" alt="Edit"/></a> &nbsp;&nbsp;
							<a href="<?= $self?>?del=<?=$sp['id'] ?>" onclick="return confirm('Do you want delete this?')" title="Delete"><img src="images/del_icon.gif" width="16" height="16" alt="Delete" /></a>
						</td>
					</tr>
						<?php
					}
					?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<?php include("__footer.php"); ?>
</div>
</body>
</html>
